import {defineConfig} from 'vite'
import uni from '@dcloudio/vite-plugin-uni'
import TailwindCli from './vite-plugin-tailwind-cli'

/** ==== 读取pages.json内容 ==== */
const readPages = require('./uni-read-pages-vite.js')
const pageJson = readPages()

export default defineConfig({
    plugins: [
        /** tailwindcss cli 打包 */
        TailwindCli({
            command: process.env.NODE_ENV === 'production' ? 'npm run tailwind:build' : 'npm run tailwind:dev',
            async: process.env.NODE_ENV === 'production',
        }),
        uni(),
    ],
    // 定义全局变量 @doc https://cn.vitejs.dev/config/shared-options.html#define
    define: {
        UNI_PAGES: pageJson.pages,
    },
})
